#!/bin/bash

echo "==================== 激光雷达点云显示测试 ===================="

# 设置ROS环境
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash

# 检查roscore是否运行
if ! pgrep -x "roscore" > /dev/null; then
    echo "错误: roscore未运行，请先启动roscore。"
    exit 1
fi

# 检查激光雷达话题是否存在
echo "检查激光雷达话题..."
rostopic list | grep -q "/rslidar_points"
if [ $? -eq 0 ]; then
    echo "✓ 激光雷达话题 /rslidar_points 存在"
else
    echo "✗ 激光雷达话题 /rslidar_points 不存在"
    echo "请先启动激光雷达节点："
    echo "roslaunch scout_bringup open_rslidar.launch"
    exit 1
fi

# 编译项目
echo "编译项目..."
cd ~/catkin_ws
catkin_make

if [ $? -eq 0 ]; then
    echo "✓ 编译成功"
else
    echo "✗ 编译失败"
    exit 1
fi

# 启动激光雷达显示节点
echo "启动激光雷达点云显示节点..."
rosrun scout_sensor_monitor lidar_display_node
